<template>
	<view>
		<van-nav-bar title="我的收藏" left-text="返回" left-arrow @click-left="onClickLeft" />
		<view class="box">
			<view v-show="Pitera" style="margin: 100px auto;">
				<van-empty description="暂无收藏" />
			</view>
			<view class="goods" v-for="(item,index) in collect" :key="index">
				<view class="">
					<img @click="jump(item)" style="width: 320rpx;height: 320rpx;border-radius:5%;margin-left: 10rpx;" :src="item.commodityImg" alt="">
				</view>
				<view style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;font-weight: bold;">
					{{item.commodityName}}
				</view>
				<view style="width: 350rpx;">
					<span style="color: red;font-weight: bold;">￥{{item.currentPrice}}</span>
					<span style="text-decoration: line-through;margin-left: 100rpx;color: gray;">￥{{item.originalPrice}}</span>
				</view>
				<view style="display: flex;align-items: center;">
					<img style="width: 50rpx;height: 50rpx;border-radius:100%;" :src="item.userPhoto" alt="">
					<span style="width: 280rpx; margin-left:20rpx ;color: gray;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">{{item.userName}}</span>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../com/request.js'
	export default {
		data() {
			return {
				collect:[],
				Pitera:true
			}
		},
		methods: {
			onClickLeft() {
				uni.redirectTo({
					url: '/pages/MyCenter/MyCenter'
				})
			  },
			jump(item){
				uni.setStorageSync('hx220408commodityId',item.commodityId)
				uni.setStorageSync('hx220408userTel',item.userTel)
				uni.redirectTo({
					url: '/pages/goods/goods'
				})
			}
		},
		onLoad(){
			request({
					url:'api/MyCollect/get',
					methods:'get',
					data:{
					  acc:uni.getStorageSync("userTel")
					},
					success: (resp) => {
						this.collect=resp.data.data
						if(this.collect.length>0){
							this.Pitera=false
						}else{
							this.Pitera=true
						}
						console.log(this.collect,46);
					}
				})
		}
	}
</script>

<style>
.goods{
	width: 350rpx;
	margin-left: 22rpx;
	margin-top: 15px;
}
.box{
	display:flex;
	flex-wrap: wrap;
}
</style>
